package com.foreveross.mofang.serviceconsole.core;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * 任务模样
 * 
 * @author fb
 */
@Entity
@Table(name = "MF_TASKTEMPLATE")
public class TaskTemplate extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@NotNull
	@Column(name = "NAME")
	private String name;

	// 所属渠道
	@ManyToOne
	@JoinColumn(name = "CHANNEL_ID")
	private Channel channel;
	
	// 所属组
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "GROUP_ID")
	private ChannelGroup group;
	
	// 页面字符集 UTF-8,GBK，自动识别等
	@NotNull
	@Column(name = "CODING")
	private String pageCoding;
	
	/*@ElementCollection
	@CollectionTable(name = "MF_FREQUENCY", joinColumns = @JoinColumn(name = "TASKTEMPLATE_ID"))
	private List<Frequency> frequency;*/
	
	// 执行频度cron 表达式
	private String cronExpress;
	
	@Column(name = "LASTGENERATE_DATE")
	private Date lastGenerateDate;
	
	
	// 请求参数集	字符串	JSON数据，将会转换为对象，在适配器中使用
	@Column(name = "JSON_PARAMS")
	private String paramsJson;
	
	// 对jsonParams进行描述的元数据，格式为json
	@Column(name = "JSON_METADATA")
	private String metadata;
 
	// 是否可用状态
	@Column(name = "ISENABLED")
	private Boolean isEnabled = true;
	
	public Channel getChannel() {
		return channel;
	}

	public void setChannel(Channel channel) {
		this.channel = channel;
	}

	public String getPageCoding() {
		return pageCoding;
	}

	public void setPageCoding(String pageCoding) {
		this.pageCoding = pageCoding;
	}

	public String getCronExpress() {
		return cronExpress;
	}

	public void setCronExpress(String cronExpress) {
		this.cronExpress = cronExpress;
	}

	public String getParamsJson() {
		return paramsJson;
	}

	public void setParamsJson(String paramsJson) {
		this.paramsJson = paramsJson;
	}

	public String getMetadata() {
		return metadata;
	}

	public void setMetadata(String metadata) {
		this.metadata = metadata;
	}

	public ChannelGroup getGroup() {
		return group;
	}

	public void setGroup(ChannelGroup group) {
		this.group = group;
	}

	public Date getLastGenerateDate() {
		return lastGenerateDate;
	}

	public void setLastGenerateDate(Date lastGenerateDate) {
		this.lastGenerateDate = lastGenerateDate;
	}

	public Boolean getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(Boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

}
